/**
 * 
 */
package neptune.web.client.view.input;

/**
 * @author Roberto Bifulco [RobertoBifulco.it] [info@robertoBifulco.it]
 *
 */
public class IPInputValidator implements InputValidator
{

	/* (non-Javadoc)
	 * @see neptune.web.client.view.input.InputValidator#isValid(java.lang.String)
	 */
	public  boolean isValid(String input) 
	{
		//TODO da rivedere
		try
		{
			if (input.equalsIgnoreCase("127.0.0.1")) return false;
			String[] block = input. split("\\.");
			if  ( block.length != 4 ) return false;
			if (Integer.valueOf(block[0])< 0 || Integer.valueOf(block[0])>255 ) return false;
			if (Integer.valueOf(block[1])< 0 || Integer.valueOf(block[1])>255 ) return false;
			if (Integer.valueOf(block[2])< 0 || Integer.valueOf(block[2])>255 ) return false;
			if (Integer.valueOf(block[3])< 0 || Integer.valueOf(block[3])>255 ) return false;
			return true;
		}
		catch(java.lang.Exception e)
		{
			e.printStackTrace();
			return false;
		}
	}
	


}
